#include<bits/stdc++.h>
using namespace std;
//long long     !!!!
//freopen        !!!
// many tests      CLEAR   !!!!
int n,T,m,L,V,s,v,ac,d,t1,pl,pr,nt,j;
struct node{
    int l,r;
}a[100010];
node c[100010];
int b[100010];
bool cmp(node a,node b){
    return a.r<b.r;
}
int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){
        if(ch=='-') f=-1;
        ch=getchar();
    }while(ch>='0'&&ch<='9'){
        x=(x<<3)+(x<<1)+(ch^48);
        ch=getchar();
    }return x*f;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout); 
    T=read();
    for(int I=1;I<=T;I++){
        n=read();m=read();L=read();V=read();
        for(int i=1;i<=n;i++){//read cars information
            s=read();v=read();ac=read();
            if(ac>0){
                if(v>V){
                    a[i].l=s;a[i].r=L;
                }else{
                    d=(V*V-v*v)/(1.0*ac*2)+1;

                    if(s+d>L) a[i].l=a[i].r=-1;
                    else{
                        a[i].l=d+s;a[i].r=L;
                    }
                }
            }else if(ac<0){
                ac=-ac;
                if(v<V){
                    a[i].l=a[i].r=-1;
                }else{
                    if((v*v-V*V)%(ac*2)==0) d=(v*v-V*V)/(ac*2)-1;
                    else d=(v*v-V*V)/(1.0*ac*2);

                    if(s+d>L){
                        a[i].l=s;a[i].r=L;
                    }else{
                        a[i].l=s;a[i].r=s+d;
                    }
                }
            }else{
                if(v>V){
                    a[i].l=s;a[i].r=L;
                }else{
                    a[i].l=a[i].r=-1;
                }
            }
        }
        for(int i=1;i<=m;i++){
            b[i]=read();
        }
        
        t1=0;
        for(int i=1;i<=n;i++){
            if(a[i].l==-1) continue;
            //cout<<a[i].l<<a[i].r<<" ";
            pl=lower_bound(b+1,b+m+1,a[i].l)-b;
            pr=upper_bound(b+1,b+m+1,a[i].r)-b-1;
            if(pl>pr) continue;
            c[++t1].l=pl;c[t1].r=pr;
        }cout<<t1<<" ";
        if(t1==0){
            cout<<m<<"\n";
            continue;
        }
        sort(c+1,c+t1+1,cmp);
        nt=1;j=c[1].r;
        for(int i=2;i<=t1;i++){
            if(c[i].l>j){
                j=c[i].r;nt++;
            }
        }cout<<m-nt<<"\n";
    }
    return 0;
}